﻿using AutoMapper;
using Comm100.Application.Services;
using Comm100.Framework.Auditing;
using Comm100.Framework.Authorization;
using Comm100.Public.Audit;
using Bot.Application.Dto;
using Bot.Application.Services;
using Bot.Domain.Bo;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using Bot.Domain;

namespace Bot.Application.OveragePackages.Service
{
    public class OveragePackageAppService : BaseAppService, IOveragePackageAppService
    {
        private IOveragePackageDomainService _domainService;

        public OveragePackageAppService(IOveragePackageDomainService domainService) : base()
        {
            this._domainService = domainService;
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.OVERAGEPACKAGE, AuditAction.DESTROY)]
        public void Delete(Guid id)
        {
            _domainService.Delete(id);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.OVERAGEPACKAGE, AuditAction.CREATE)]
        public OveragePackageDto Add(OveragePackageCreateDto dto)
        {
            OveragePackage overagePackage = _domainService.Create(Mapper.Map<OveragePackage>(dto));
            return Mapper.Map<OveragePackageDto>(overagePackage);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        [Audit(BotEntity.OVERAGEPACKAGE, AuditAction.UPDATE)]
        public OveragePackageDto Update(OveragePackageUpdateDto dto)
        {
            OveragePackage overagePackage = _domainService.Update(Mapper.Map<OveragePackageUpdateBo>(dto));
            return Mapper.Map<OveragePackageDto>(overagePackage);
        }

        public OveragePackageDto Get(Guid id)
        {
            OveragePackage overagePackage = _domainService.Get(id);
            return Mapper.Map<OveragePackageDto>(overagePackage);
        }

        public IEnumerable<OveragePackageDto> GetList()
        {
            IEnumerable<OveragePackage> list = _domainService.List();
            return Mapper.Map<IEnumerable<OveragePackageDto>>(list);
        }
    }
}
